﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Path类操作路径字符串
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string dir = @"C:\Users\UnityPC\Desktop\";
            string name = @"新建文本文档 (3).txt";

            string path = Path.Combine(dir, name);
            //自动加 \
            Console.WriteLine();

            Console.WriteLine(Path.GetFileName(path));//获取文件名
            Console.WriteLine(Path.GetFileNameWithoutExtension(path));//没有扩展名的文件名
            Console.WriteLine(Path.GetExtension(path));//扩展名
            Console.WriteLine(Path.GetFullPath("name.txt"));
        }
    }
}